<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="ss"%>

<jsp:include page="../header.jsp" />
<script type="text/javascript">
	function makeReservation(bookId) {
		var userId =<%=session.getAttribute("userId")%>;
		window.location = "/isLibrary/users/makeReservation.do?userId="
				+ userId + "&bookId=" + bookId;
	}
</script>
<div id="content">
	<div id="topstory" class="box">
		<h1>
			<fmt:message key="book.title.list" />
		</h1>
	</div>

	<div class="padding">
		<c:if test="${not empty message}">
			<div class="ui-widget">
				<div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;">
					<p>
						<span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span> <strong>Info !</strong>
						<c:out value="${message }" />
					</p>
				</div>
			</div>
		</c:if>
		<div>
			<form:form action="/isLibrary/books/find.do" commandName="bookView" method="POST" >
				<table border="0" cellspacing="5" cellpadding="0" width="100%" class="formTable tplBorder">
					<tr>
						<td width="15%"></td>
						<td width="35%"></td>
						<td width="15%"></td>
						<td width="35%"></td>
					</tr>
					<tr>
						<td class="label"><fmt:message key="book.name" /></td>
						<td><form:input path="nazev" /> <form:errors path="nazev" cssStyle="color: red;" /></td>
						<td colspan="2"></td>
					</tr>
					<tr>
						<td colspan="2"><input type="submit" /></td>
					</tr>
				</table>
			</form:form>
		</div>
		<display:table export="true" id="data" name="knihaList" requestURI="/books.do" decorator="cz.boxdesign.library.web.decorator.BookTableDecorator" pagesize="10">
			<ss:authorize access="hasRole('ROLE_ADMIN')">
				<display:column property="editUrl" title="Edit" sortable="false" />
				<display:column property="deleteUrl" title="Edit" sortable="false" />
			</ss:authorize>
			<ss:authorize access="hasAnyRole('ROLE_ADMIN','ROLE_USER')">
				<display:column property="makeReservationUrl" title="Edit" sortable="false" />
			</ss:authorize>
			<display:column property="showUrl" title="Show" sortable="false" />
			<display:column property="nazev" title="Nazev" sortable="true" />
			<display:column property="oddeleniLink" title="Oddeleni" sortable="true" />
			<display:column property="nakladatelstviLink" title="Nakladatelstvi" sortable="true" />
			<display:column property="pocetKnih" title="Pocet kusu" sortable="true" />
			<display:column property="rokVydani" title="Rok Vydani" sortable="true" />
		</display:table>
	</div>
	<!-- /padding -->
</div>
<!-- /content -->
<jsp:include page="side-menu.jsp" />
<jsp:include page="../foother.jsp" />
